package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.business.domain.CzTaskType;
import com.ruoyi.business.service.ICzTaskTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务类型Controller
 * 
 * @author ruoyi
 * @date 2022-02-08
 */
@Api(tags = "任务类型")
@RestController
@RequestMapping("/business/task_type")
public class CzTaskTypeController extends BaseController
{
    @Autowired
    private ICzTaskTypeService czTaskTypeService;

    /**
     * 查询任务类型列表
     */
    @ApiOperation(value = "查询任务类型列表")
    @PreAuthorize("@ss.hasPermi('business:task_type:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzTaskType czTaskType)
    {
        startPage();
        List<CzTaskType> list = czTaskTypeService.selectCzTaskTypeList(czTaskType);
        return getDataTable(list);
    }

    /**
     * 导出任务类型列表
     */
    @ApiOperation(value = "导出任务类型列表")
    @PreAuthorize("@ss.hasPermi('business:task_type:export')")
    @Log(title = "任务类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzTaskType czTaskType)
    {
        List<CzTaskType> list = czTaskTypeService.selectCzTaskTypeList(czTaskType);
        ExcelUtil<CzTaskType> util = new ExcelUtil<CzTaskType>(CzTaskType.class);
        util.exportExcel(response, list, "任务类型数据");
    }

    /**
     * 获取任务类型详细信息
     */
    @ApiOperation(value = "获取任务类型详细信息")
    @PreAuthorize("@ss.hasPermi('business:task_type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(czTaskTypeService.selectCzTaskTypeById(id));
    }

    /**
     * 新增任务类型
     */
    @ApiOperation(value = "新增任务类型")
    @PreAuthorize("@ss.hasPermi('business:task_type:add')")
    @Log(title = "任务类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzTaskType czTaskType)
    {
        return toAjax(czTaskTypeService.insertCzTaskType(czTaskType));
    }

    /**
     * 修改任务类型
     */
    @ApiOperation(value = "修改任务类型")
    @PreAuthorize("@ss.hasPermi('business:task_type:edit')")
    @Log(title = "任务类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzTaskType czTaskType)
    {
        return toAjax(czTaskTypeService.updateCzTaskType(czTaskType));
    }

    /**
     * 删除任务类型
     */
    @ApiOperation(value = "删除任务类型")
    @PreAuthorize("@ss.hasPermi('business:task_type:remove')")
    @Log(title = "任务类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(czTaskTypeService.deleteCzTaskTypeByIds(ids));
    }
}
